chrome.contextMenus.create({
    "type": "normal",
    "checked": false,
    "id": "ttttt",
    "title": "ttttt",
    "contexts": ["page"]
});
chrome.contextMenus.onClicked.addListener(function (info, tab) {
    console.log("#####");
    console.log(info, tab);
    chrome.cookies.getAll({ "url": info.pageUrl }, function (c) {
        console.log("chrome.cookies.getAll", c);
    });
    chrome.cookies.getAllCookieStores(function (c) {
        console.log("chrome.cookies.getAllCookieStores", c);
    });
    chrome.windows.getCurrent(function (tab) {
        console.log("chrome.windows.getCurrent", tab);
    });

});

chrome.alarms.create('refreshDkkPage', { periodInMinutes: 60 });
var dkkkRefreshUrl = 'http://dk.com';
chrome.alarms.onAlarm.addListener(function (alarm) {
    if (alarm.name == 'refreshDkkPage') {
        setTimeout(function () {
            console.log(alarm);
            chrome.windows.getAll({},
                function (w) {
                    console.log(w);
                    for (var i = 0; i < w.length; i++) {
                        var wId = w[i].id;
                        chrome.tabs.getAllInWindow(wId,
                            function (t) {
                                console.log(t);
                                for (var j = 0; j < t.length; j++) {
                                    if (t[j].url.startsWith(dkkkUrl)) {
                                        var tId = t[j].id;
                                        chrome.tabs.reload(tId);
                                    }
                                }
                            }
                        )
                    }
                }
            )
        }, Math.floor(Math.random() * 555555));
    }
})

//
var notification = chrome.notifications.create("ttttt", {
    type: 'basic',
    title: ' ',
    message: '启动了',
    iconUrl: 'icon.png'
});
